﻿@{
    ViewBag.Title = "ProjectTaskList";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model List<DepartmentWork.Model.ProjectTaskViewModel>
    <link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
<script src="~/Assets/js/pages/form-elements.js"></script>
    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }
    </style>

<script>

    window.onload = function ()
    {
        $("#datetimepicker").datepicker({
            autoclose: true,
            pickerPosition: "bottom-right"
        });
        $("#edit_datetimepicker").datepicker({
            autoclose: true,
            pickerPosition: "bottom-right"
        });
    };
        
    function DelTask(taskId)
    {
        if (!confirm("请确认是否删除该任务？"))
        {
            return false;
        }
        window.location.href = '@Url.Action("DeleteTask", "Task", new { area = "DevelopArea" })' + '?taskId=' + taskId;
    }

</script>


<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index", "Home", new { area = "" })"><i class="icon fa fa-home"></i>主页</a></li>
            <li><a href="@Url.Action("Index", "Project", new { area = "DevelopArea" })"><i class="fa fa-envelope"></i>开发模块</a></li>
            <li><a href="@Url.Action("ProjectInfo", "Project", new { area = "DevelopArea", projectId = ViewBag.ProjectId })"><i class="fa fa-envelope"></i>项目详情</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>任务</a></li>
        </ol>
    </div>
</div>

@{
    if (ViewBag.Flag == "CreateTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;任务添加成功！</strong>
    </div>
    }
    if (ViewBag.Flag == "CreateFalse")
    {
      <div class="alert alert-danger">
	    <button type="button" class="close" data-dismiss="alert">×</button>
	    <strong>&emsp;任务添加失败！</strong> @ViewBag.Info
    </div>
    }

    if (ViewBag.Flag == "EditTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;任务编辑成功！</strong>
    </div>
    }
    if (ViewBag.Flag == "EditFalse")
    {
      <div class="alert alert-danger">
	    <button type="button" class="close" data-dismiss="alert">×</button>
	    <strong>&emsp;任务辑失败！</strong> @ViewBag.Info
    </div>
    }

    if (ViewBag.Flag == "DelTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;任务删除成功！</strong>
    </div>
    }
    if (ViewBag.Flag == "DelFalse")
    {
      <div class="alert alert-danger">
	    <button type="button" class="close" data-dismiss="alert">×</button>
	    <strong>&emsp;任务删除失败！</strong> @ViewBag.Info
    </div>
    }




    if (ViewBag.Flag == "SubmitTrue")
    {
        <div class="alert alert-success">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>&emsp;任务提交成功！</strong>
        </div>
    }
    if (ViewBag.Flag == "SubmitFalse")
    {
        <div class="alert alert-danger">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>&emsp;任务提交失败！</strong> @ViewBag.Info
        </div>
    }

    if (ViewBag.Flag == "PassTrue")
    {
        <div class="alert alert-success">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>&emsp;任务审核成功！</strong>
        </div>
    }
    if (ViewBag.Flag == "PassFalse")
    {
        <div class="alert alert-danger">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>&emsp;任务审核失败！</strong> @ViewBag.Info
        </div>
    }

    if (ViewBag.Flag == "ReturnTrue")
    {
        <div class="alert alert-success">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>&emsp;任务退回成功！</strong>
        </div>
    }
    if (ViewBag.Flag == "ReturnFalse")
    {
        <div class="alert alert-danger">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>&emsp;任务退回失败！</strong> @ViewBag.Info
        </div>
    }

}


<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span style="font-size: medium" class="break">@ViewBag.ProjectName  项目的 任务</span></h6>
                
               @{
                   if (ViewBag.IsDevelopLeader == true)
                   {
                        <div class="panel-actions">
                            <a onclick="RestCreate()" data-toggle="modal" data-target="#TaskBookCreateModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;新增任务&nbsp;&nbsp;</a>
                        </div>
                   }
                }


            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>任务名称</th>
                                <th>创建人</th>
                                <th>创建时间</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @{
                                for (int i = 0; i < this.Model.Count(); i++)
                                {
                                    var item = this.Model[i];
                                    <tr >
                                        <td >
                                            <a style="color:cornflowerblue" data-toggle="modal" onclick="ShowTaskInfoModal('@item.TaskId')" data-target="#TaskInfoModal">@item.TaskName</a>
                                             
                                        </td>
                                        <td>@item.Creater</td>
                                        <td>@item.TaskCreateTime</td>
                                        <td>
                                            @{
                                    if (item.TaskCheckState == 0)
                                    {
                                                   <span style="font-size: small" class="label label-warning">未提交</span>
                                    }
                                    else if (item.TaskCheckState == 2)
                                    {
                                        if (item.Status!=3)
                                        {
                                                 <span style="font-size: small" class="label label-success">按时完成</span>
                                        }
                                        else
                                        {
                                                 <span style="font-size: small" class="label label-default">超时完成</span>
                                        }
                                    }
                                    else
                                    {
                                        switch (item.Status)
                                        {
                                            case 0:
                                                <span style="font-size: small" class="label label-warning">进行中</span>
                                                break;
                                            case 3:
                                                <span style="font-size: small" class="label label-danger">进行中（已超时）</span>
                                                break;
                                            
                                        }
                                    }


                                            }
                                        </td>
                                        <td>
                                            @{
                                            @* 判断如果是项目管理员 或 是该任务的创建者 则 可以编辑 删除 提交 *@
                                    if (ViewBag.IsDevelopLeader == true || item.CreaterId == CurrentUser.UserID || item.HandToUser == CurrentUser.UserID)
                                    {
                                        if (item.TaskCheckState == 0 && (ViewBag.IsDevelopLeader == true || item.CreaterId == CurrentUser.UserID))
                                        {
                                                        <a style="color:cornflowerblue" data-toggle="modal" onclick="ShowTaskEditModal('@item.TaskId')" data-target="#TaskEditModal">编辑</a>
                                                        @:&nbsp; &nbsp; &nbsp; 
                                                    }
                                        if (ViewBag.IsDevelopLeader == true || item.CreaterId == CurrentUser.UserID)
                                        {
                                                          <a style="color:cornflowerblue" class="a_DeleteTask" onclick="DelTask('@item.TaskId')" >删除</a>
                                                        @:&nbsp; &nbsp; &nbsp; 
                                                    }

                                        if (item.TaskCheckState == 0)
                                        {
                                                        <a style="color:cornflowerblue" href="@Url.Action("SubmitTask", "Task", new { area = "DevelopArea", TaskId = item.TaskId })">提交</a>
                                        }
                                        else if (ViewBag.IsDevelopLeader == true && item.TaskCheckState == 1)
                                        {
                                                       
                                                        <a style="color:cornflowerblue"  href="@Url.Action("PassTask", "Task", new { area = "DevelopArea", TaskId = item.TaskId })">审核</a>
                                                         @:&nbsp; &nbsp; &nbsp;
                                                       
                                                        <a style="color:cornflowerblue" href="@Url.Action("ReturnTask", "Task", new { area = "DevelopArea", TaskId = item.TaskId })">退回</a>
                                                        @:&nbsp; &nbsp; &nbsp;
                                                    }
                                        else if (item.TaskCheckState == 2)
                                        {

                                            if (ViewBag.IsDevelopLeader == true)
                                            {
                                                                  <a style="color:cornflowerblue" class="a_DeleteTask" onclick="DelTask('@item.TaskId')" >删除</a>
                                                                 @:&nbsp; &nbsp; &nbsp; 
                                                        }

                                        }
                                    }
                                            }
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>
                     <div class="bk-margin-5 btn-group" style="float: right">
                          @Html.ShowPageNavigate((int)ViewData["pageIndex"], (int)ViewData["pageSize"], (int)ViewData["total"], (string)ViewBag.ProjectId)
                     </div>
                </div>
            </div>
        </div>
    </div>
</div>


@{
    List<UserInfoViewModel> userList = (List<UserInfoViewModel>)TempData["UserList"];
}

<!-- 任务详情 模态框（Modal） -->

<script>
    function ShowTaskInfoModal(taskId) {
        //alert(data["Status"]);
        $.ajax({
            type: "POST",
            //url: "/KSManager/DevelopArea/Task/GetTaskInfo",
            url:'@Url.Action("GetTaskInfo","Task",new{area="DevelopArea"})',
            data: "taskId=" + taskId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                // $("#TaskBookInfoModal").attr("aria-hidden", "true");
                $("#lb_TaskName").text(data["TaskName"]);
                $("#lb_TaskCreater").text(data["Creater"]);
                $("#lb_TaskHandToUser").text(data["HandToUser"]);
                
                var content = "";
                for (var i = 0; i < data["TaskContext"].length; i++)
                {
                    if (i % 35 == 0 && i != 0)
                    {
                        content += data["TaskContext"][i] + "<br/>";
                    } else
                    {
                        content += data["TaskContext"][i];
                    }

                }
                $("#lb_TaskContext").html(content);



                $("#lb_TaskCreateTime").text(data["TaskCreateTime"]);
                $("#lb_TaskHour").text(data["Hour"]);
                if (data["Status"]==0) {
                    $("#lb_TaskStatus").text('任务进行中');
                }
                else if (data["Status"]==1) {
                    $("#lb_TaskStatus").text('任务进行中但任务超时');
                }
                else if (data["Status"]==2) {
                    $("#lb_TaskStatus").text('任务完成');
                }
                else if (data["Status"]==3) {
                    $("#lb_TaskStatus").text('任务超时完成');
                }
                
                if (data["Level"]==0) {
                    $("#lb_TaskLevel").text('低');
                }
                else if (data["Level"]==1) {
                    $("#lb_TaskLevel").text('中');
                }
                else if (data["Level"]==2) {
                    $("#lb_TaskLevel").text('高');
                }
                
                if (data["TaskBookFileSaveName"] == "")
                {
                    //$("#lb_TaskFile").text("");
                    $("#a_DownloadTaskFile").text("");
                } else
                {
                    //$("#lb_TaskFile").text(data["TaskFileShowName"]);
                    $("#a_DownloadTaskFile").text(data["TaskFileShowName"]);
                    //$("#a_DownloadTaskFile").attr("href", "http:////" + data["TaskFilePath"] + '//' + data["TaskFileSaveName"]);
                    $("#a_DownloadTaskFile").attr("href", '@Url.Content("~/Home/DownLoadFile?filePath=")' + data["TaskFileSaveName"] + "&type=Task&fileName=" + data["TaskFileSaveName"]);

                }

            }
        });
    }

</script>

<div class="modal fade" id="TaskInfoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" >
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">任务详情
                </h4>
            </div>
            <div class="modal-body" style="font-size: small"> 
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input" >任务名称：</label>
                    <div class="col-md-9">
                        <label id="lb_TaskName" style="width:100%"  class="col-md-3 control-label" for="text-input"></label>
                    </div>
                </div>
                <hr/>

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">创建人：</label>
                    <div class="col-md-9">
                        <label id="lb_TaskCreater"  style="width:100%"  class="col-md-8 control-label" for="text-input">任务01</label>
                    </div>
                </div>
                <hr/>
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务分配人：</label>
                    <div class="col-md-9">
                        <label id="lb_TaskHandToUser"  style="width:100%"  class="col-md-8 control-label" for="text-input"></label>
                    </div>
                </div>
                <hr/>
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务级别：</label>
                    <div class="col-md-9">
                        <label id="lb_TaskLevel"  style="width:100%"  class="col-md-8 control-label" for="text-input"></label>
                    </div>
                </div>
                <hr/>
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务状态：</label>
                    <div class="col-md-9">
                        <label id="lb_TaskStatus"  style="width:100%"  class="col-md-8 control-label" for="text-input"></label>
                    </div>
                </div>
                <hr/>

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务详情：</label>
                    <div class="col-md-9">
                        <label  id="lb_TaskContext"  style="width:100%"  class="col-md-8 control-label" for="text-input">任务书01</label>
                    </div>
                </div>

                <hr/>
                
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务所需时间：</label>
                    <div class="col-md-9">
                         <label  id="lb_TaskHour" class="col-md-8 control-label" ></label>
                    </div>
                </div>
                <br />
                    <hr/>
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务创建时间：</label>
                    <div class="col-md-9">
                        <label id="lb_TaskCreateTime"  class="col-md-8 control-label" for="text-input"></label>
                    </div>
                </div>
                <hr/>

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务附件：</label>
                    <div class="col-md-9">
                        <a id="a_DownloadTaskFile">
                             @* <label  id="lb_TaskFile"  class="col-md-8 control-label" for="text-input"></label>*@
                        </a>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<!-- 编辑任务 模态框（Modal） -->

<script>
    function ShowTaskEditModal(taskId) {
        $("#hid_EditTaskId").val(taskId);
        $.ajax({
            type: "POST",
            //url: "/KSManager/DevelopArea/Task/GetTaskInfo",
            url:'@Url.Action("GetTaskInfo","Task",new{area="DevelopArea"})',
            data: "taskId=" + taskId,
            error: function () { alert("服务器出错！"); },
            success: function (data)
            {
                // $("#TaskBookInfoModal").attr("aria-hidden", "true");
                //$("#hid_EditTaskId").val(taskId);
                $("#tb_TaskName").val(data["TaskName"]);
                $("#tb_TaskCreater").val(data["Creater"]);
                $("#tb_TaskContext").text(data["TaskContext"]);
                //$("#select_EditTaskLevel").val(data["TaskCreateTime"]);
                $("#tb_Hour").val(data["Hour"]);
                $("#tb_DeadTime").val(data["TaskDeadTime"]);//截止日期
                //$("#edit_datetimepicker").val(data["TaskCreateTime"]);
                $("#edit_datetimepicker").attr('data-date',data["TaskDeadTime"]);

                $("#select_EditTaskHandToUser option").each(function() {
                    if ($(this).text()==data["Creater"]) {
                        $(this).attr("selected", "selected");
                    }
                });
                $("#select_EditTaskLevel option").each(function() {
                    if ($(this).val()==data["Level"]) {
                        $(this).attr("selected", "selected");
                    }
                });

                if (data["TaskBookFileSaveName"] == "")
                {
                    $("#lb_TaskInfo_OldFile").text("");
                } else
                {
                    $("#lb_TaskInfo_OldFile").text(data["TaskFileShowName"]);
                    //$("#a_DownloadOldTaskFile").attr("href", "http:////" + data["TaskFilePath"] + '//' + data["TaskFileSaveName"]);
                    $("#lb_TaskInfo_OldFile").attr("href", '@Url.Content("~/Home/DownLoadFile?filePath=")' + data["TaskFileSaveName"] + "&type=Task&fileName=" + data["TaskFileSaveName"]);

                }

            }
        });
    }

</script>

<div class="modal fade" id="TaskEditModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">编辑任务
                </h4>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("EditTask", "Task", new { area = "DevelopArea" })" method="POST" >
            <div class="modal-body">
                <input type="hidden" id="hid_EditTaskId" name="hid_EditTaskId"/>
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务名称：</label>
                    <div class="col-md-9">
                        <input id="tb_TaskName" style="border-color: cornflowerblue" name="tb_TaskName" class="form-control" placeholder="Text" type="text">
                    </div>
                </div>
                <br />

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务创建人：</label>
                    <div class="col-md-9">
                        <input id="tb_TaskCreater" style="border-color: cornflowerblue" name="tb_TaskCreater" class="form-control" placeholder="Text" type="text">
                    </div>
                </div>
                <br />
                
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务分配人：</label>
                    <div class="col-md-9">
                        <select name="select_EditTaskHandToUser" id="select_EditTaskHandToUser" class="form-control selectpicker">
                             @{
                                 if (userList != null)
                                 {
                                     for (int i = 0; i < userList.Count(); i++)
                                     {
                                                <option value="@userList[i].UserId">@userList[i].UserName</option>
                                     }
                                 }
                                    }
                                </select>
                    </div>
                </div>
                <br />

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务详情：</label>
                    <div class="col-md-9">
                        <textarea id="tb_TaskContext" name="tb_TaskContext" class="form-control" rows="3"></textarea>
                    </div>
                </div>
                <br />
                
                <div class="row">
                        <label class="col-md-3 control-label">截至日期：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="edit_datetimepicker"  data-date-format="yyyy-mm-dd">
                                <input name="tb_DeadTime" id="tb_DeadTime" style="border-color: cornflowerblue" class="form-control" size="16" type="text">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>

                        </div>
                    </div>

                    <br />
                
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务级别：</label>
                    <div class="col-md-9">
                        <select name="select_EditTaskLevel" id="select_EditTaskLevel" class="form-control selectpicker">
                            <option value="0">低</option>
                            <option value="1">中</option>
                            <option value="2">高</option>
                        </select>
                    </div>
                </div>
                <br />
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">任务所需时间：</label>
                    <div class="col-md-9">
                        <input id="tb_Hour" style="border-color: cornflowerblue" name="tb_Hour" class="form-control" placeholder="Text" type="text">
                    </div>
                </div>
                <br />

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">原附件：</label>
                    <div class="col-md-9">
                        <a  style="color:cornflowerblue" id="a_DownloadOldTaskFile">
                            <label id="lb_TaskInfo_OldFile" class="col-md-8 control-label" for="text-input"></label>
                        </a>
                    </div>
                </div>
                <br />
                
                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">附件：</label>
                    <div class="col-md-9">
                        <input id="tb_TaskFile" style="border-color: cornflowerblue" name="tb_TaskFile" class="form-control" placeholder="Text" type="file">
                    </div>
                </div>
                <br />

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
                <input type="submit" class="btn btn-primary"  value="提交更改"/>
            </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<!-- 新增任务 模态框（Modal） -->

<script>
    function RestCreate() {
        $("#lb_CheckCreateTaskMessage").html("");
    }
</script>

<div class="modal fade" id="TaskBookCreateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">新增任务
                </h4>
            </div>
            <form id="frm_CreateTask" enctype="multipart/form-data" action="@Url.Action("CreateTask", "Task", new { area = "DevelopArea" })" method="POST" >
                <div class="modal-body" >
                   <div class="alert alert-danger" id="div_CheckCreateTaskMessage" style="display:none">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong><label id="lb_CheckCreateTaskMessage"></label></strong>
                    </div>
                    <div class="row">
                        <input  type="hidden" value="@ViewBag.ProjectId" name="hid_ProjectId"/>
                        <label class="col-md-3 control-label" for="text-input">任务名称：</label>
                        <div class="col-md-9">
                            <input id="tb_CreateTaskName" style="border-color: cornflowerblue" name="tb_TaskName" class="form-control" placeholder="Text" type="text">
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">任务创建人：</label>
                        <div class="col-md-9">
                            <input id="tb_CreateTaskCreater" disabled="disabled" style="border-color: cornflowerblue" name="tb_TaskCreater" value="@CurrentUser.UserName" class="form-control" placeholder="Text" type="text">
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">任务分配人：</label>
                        <div class="col-md-9">
                            <select name="select_TaskHandToUser" id="select_CreateTaskHandToUser" class="form-control selectpicker">
                                @{
                                       
                                    if (userList != null)
                                    {
                                        for (int i = 0; i < userList.Count(); i++)
                                        {
                                            <option value="@userList[i].UserId">@userList[i].UserName</option>
                                        }
                                    }
                                }
                            </select>
                        </div>
                    </div>
                    <br />
                
                    <div class="row">
                        <label class="col-md-3 control-label">截至日期：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="datetimepicker" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input name="tb_DeadTime" style="border-color: cornflowerblue" class="form-control" size="16" type="text" value="">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>

                        </div>
                    </div>

                    <br />
                
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">任务级别：</label>
                        <div class="col-md-9">
                            <select name="select_TaskLevel" id="select_TaskLevel" class="form-control selectpicker">
                                <option value="0">低</option>
                                <option value="1">中</option>
                                <option value="2">高</option>
                            </select>
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">任务详情：</label>
                        <div class="col-md-9">
                            <textarea id="tb_CreateTaskContext" name="tb_TaskContext" class="form-control" rows="3"></textarea>
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">任务建议所需时间（小时）：</label>
                        <div class="col-md-9">
                            <input id="tb_CreateTaskHour" style="border-color: cornflowerblue" name="tb_TaskHour" class="form-control" placeholder="Text" type="text">
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">附件：</label>
                        <div class="col-md-9">
                            <input id="tb_CreateTaskFile" style="border-color: cornflowerblue" name="tb_TaskBookFile" class="form-control" placeholder="Text" type="file">
                        </div>
                    </div>
                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="button" onclick="SubmitCreate()" class="btn btn-primary"  value="新增"/>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<script>
    function SubmitCreate()
    {
        var message = ""; 
        if ($("#tb_CreateTaskName").val() == "" || $.trim($("#tb_CreateTaskName").val()) == "")
        {
            message += " · 任务名称不能为空"+"<br/>";
        }
        if ($("#select_CreateTaskHandToUser").val() == "")
        {
            message += " · 任务分配人员不能为空" + "<br/>";
        }
        if ($("#tb_CreateTaskContext").val() == "" || $.trim($("#tb_CreateTaskContext").val()) == "")
        {
            message += " · 任务详情不能为空" + "<br/>";
        }
        if ($("#tb_CreateTaskHour").val() == "")
        {
            message += " · 任务分配时长不能为空" + "<br/>";
        }
        if (isNaN($("#tb_CreateTaskHour").val()))
        {
            message += " · 任务分配时长只能是数字" + "<br/>";
        }
        if (message != "") {
            $("#lb_CheckCreateTaskMessage").html(message);
            $("#div_CheckCreateTaskMessage").css("display", "block");
            return false;
        }
        else
        {
            $("#lb_CheckCreateTaskMessage").html("");
            $("#div_CheckCreateTaskMessage").css("display", "none");
            $("#frm_CreateTask").submit();
        }
    }
</script>
